package com.ck.dao;

import com.ck.model.chuangke.dto.CkDeviceModelDTO;
import com.ck.model.common.DeviceModel;
import com.ck.model.common.vo.DeviceModelListVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface DeviceModelMapper {
    @Delete({
        "delete from ck_device_model",
        "where device_model_id = #{deviceModelId,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long deviceModelId);

    @Insert({
        "insert into ck_device_model (device_model_id, model_name, ",
        "update_time, add_time)",
        "values (#{deviceModelId,jdbcType=BIGINT}, #{modelName,jdbcType=VARCHAR}, ",
        "#{updateTime,jdbcType=BIGINT}, #{addTime,jdbcType=BIGINT})"
    })
    int insert(DeviceModel record);

    int insertSelective(DeviceModel record);

    DeviceModel selectByPrimaryKey(Long deviceModelId);

    int updateByPrimaryKeySelective(DeviceModel record);

    @Update({
        "update ck_device_model",
        "set model_name = #{modelName,jdbcType=VARCHAR},",
          "update_time = #{updateTime,jdbcType=BIGINT},",
          "add_time = #{addTime,jdbcType=BIGINT}",
        "where device_model_id = #{deviceModelId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(DeviceModel record);

    /**
     * 获取终端型号分页列表
     * @return
     */
    Page<DeviceModelListVO> listDeviceModelByPage();

    /**
     * 通过型号名称查找终端机型信息
     * @param modelName 型号名称
     * @return
     */
    DeviceModel getDeviceModelByName(String modelName);
    
	List<CkDeviceModelDTO> listDeviceModels();
	
	/**
	 * 查询指定升级包中的机型
	 * @param deviceUpgradeId 更新ID
	 * @return List<DeviceModelDTO>
	 */
	List<CkDeviceModelDTO> listDeviceModelsSelectedUpgrade(@Param("deviceUpgradeId") Long deviceUpgradeId);
}